home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.lang.c
- Subject: Re: Unable to use 'delete' after 'new'
- Date: 23 Mar 1996 17:19:09 GMT
- Organization: Borland International
- Distribution: inet
- Message-ID: <4j1bqd$dpc@druid.borland.com>
- References: <4iudtl$eni@lisa.iosphere.net>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <4iudtl$eni@lisa.iosphere.net>, ianq@sonetis.com says...
- >
- >I have 2 definitions of new arrays that I allocate that I am unfortunately
- >having a hard time deleting afterwards.
- >
- >1 - int *iColsize = new int[cCols];
- >
- >The trick here is that I need to return this array to the calling function,
- >which then processes the data.
- >
- >How do I do the delete from the calling function as opposed to within the
- >function the NEW was executed.
- >
- >I tried the basic delete [] iColsize from the calling function, and got a
- >memory exception.
- >
- >
- >2 - char (*sPassStr)[MAX_COLSIZE + 1] = new
- >char[iColsize[0]][MAX_COLSIZE + 1];
- >
- >The problem here lies with an ODBC function I execute.
- >
- >char (*sPassStr)[MAX_COLSIZE + 1] = new char[iColsize[0]][MAX_COLSIZE + 1];
- >SQLBindCol(hstmt, i, SQL_C_CHAR, sPassStr[i], iColsize[i], &cbTemp);
- >retcode = SQLFetch(hstmt);
- >
- >Up until I do the SQLFetch, I can do a 'delete [] sPassStr' fine.
- >After the Fetch is executed, if I do a delete, I get a memory exception.
-
- You really should post this on comp.lang.c++, not comp.lang.c. Briefly, there's
- nothing in the statement of question 1 that indicates what the problem is. What
- it describes is perfectly legal and works just fine. The problem lies in the
- part that is not described in this message. Question 2 is incomprehensible.
- Learn to use typedefs. They will make your life much easier.
- -- Pete
-
-